package com.forum.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.forum.dao.NewsDao;
import com.forum.entity.news;
import com.forum.entity.view.newsView;
import com.forum.service.NewsService;
import com.forum.utils.MyQuery;
import com.forum.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @ClassNamenewsServiceImpl
 * @Author Lenovo
 * @Date 2023/12/4 22:52
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsDao, news> implements NewsService {
    @Override
    public PageUtils QueryPage(Map<String, Object> params) {
        Page<news> page = this.selectPage(
                new MyQuery<news>(params).getPage(),
                new EntityWrapper<news>()
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils QueryPage(Map<String, Object> params, Wrapper<news> wrapper) {
        Page<newsView> page =new MyQuery<newsView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,wrapper));
        PageUtils pageUtil = new PageUtils(page);
        return pageUtil;
    }

}
